﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Site.aspx.cs" Inherits="Site" %>

<%@ Register assembly="System.Web.DynamicData, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" namespace="System.Web.DynamicData" tagprefix="cc1" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="navigationPane" Runat="Server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="accountPane" Runat="Server">
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="toolbar" Runat="Server">
    <div class="breadcrumb">
        <div class="icon"><img src="" alt="" /></div>
        <div class="text">
            <div class="title"><a href="Default.aspx">Overview</a> > Site</div>
            <div class="subtitle">
                Here you can see the statistics of a selected site in detail.
            </div>
        </div>
    </div>
</asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="leftPane" Runat="Server">
    <p class="title">Statistics</p>
    <p class="link"><a href="Default.aspx">Overview</a></p>
    <p class="link"><a href="Default.aspx">Edit Page</a></p>
</asp:Content>
<asp:Content ID="Content6" ContentPlaceHolderID="bodyPane" Runat="Server">
    <asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSource1">
        <ItemTemplate>
            <h1><%# Eval("Name") %></h1>
            <p>Log file path: <strong><%# Eval("LogPath") %></strong></p>
        </ItemTemplate>
    </asp:Repeater>
    
    <h1>Current Month</h1>
    <asp:Repeater ID="Repeater2" runat="server" DataSourceID="SqlDataSource2">
        <HeaderTemplate>
            <table cellpadding="0" cellspacing="0" class="diagramLayoutVertical">
                <tr>
        </HeaderTemplate>
        <ItemTemplate>
                    <td>
                        <div class="verticalDiagramRed" style="display: inline-block">
                            <div class="block" style="height: <%# 200 - (int)(((double)200 / (double)maxScalar) * double.Parse(Eval("TrafficHTTPSent").ToString())) %>px;"></div>
                        </div>
                        <div class="verticalDiagramGreen" style="display:inline-block;">
                            <div class="block" style="height: <%# 200 - (int)(((double)200 / (double)maxScalar) * double.Parse(Eval("TrafficHTTPGet").ToString())) %>px;"></div>
                        </div><br />
                        <%# DateTime.Parse(Eval("date").ToString()).Day %>
                    </td>
        </ItemTemplate>
        <FooterTemplate>
                </tr>
            </table>
        </FooterTemplate>
    </asp:Repeater>
    
    <asp:Repeater ID="Repeater3" runat="server" DataSourceID="SqlDataSource2">
        <HeaderTemplate>
            <table cellpadding="0" cellspacing="0" class="tableLayout1">
                <tr>
                    <th>Day</th>
                    <th></th>
                    <th>Traffic outgoing</th>
                    <th>Traffic incoming</th>
                    <th>Hits</th>
                    <th>Visits</th>
                </tr>
        </HeaderTemplate>
        <ItemTemplate>
                <tr<%# (DateTime.Parse(Eval("Date").ToString()).ToString("ddd") == "So" || DateTime.Parse(Eval("Date").ToString()).ToString("ddd") == "Sa") ? " class=\"alt\"" : "" %>>
                    <td><%# DateTime.Parse(Eval("Date").ToString()).ToString("ddd") %></td>
                    <td><%# DateTime.Parse(Eval("Date").ToString()).ToString("dd.MM.yyyy") %></td>
                    <td align="center"><%# Statistics.FileSizeFormat.ToByteString(long.Parse(Eval("TrafficHTTPSent").ToString())) %></td>
                    <td align="center"><%# Statistics.FileSizeFormat.ToByteString(long.Parse(Eval("TrafficHTTPGet").ToString())) %></td>
                    <td><%# Eval("Hits") %></td>
                    <td><%# Eval("Visitors") %></td>
                </tr>
        </ItemTemplate><FooterTemplate>
            </table>
        </FooterTemplate>
    </asp:Repeater>
    
    <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
        ConnectionString="<%$ ConnectionStrings:statisticsConnectionString %>"
        
        SelectCommand="SELECT Sites.SiteId, Sites.Name, Sites.SiteName, Sites.LogPath, Traffic.Id, Traffic.SiteId AS Expr1, Traffic.Domain, Traffic.Date, Traffic.TrafficHTTPSent, Traffic.TrafficHTTPGet, Traffic.TrafficFTPSent, Traffic.TrafficFTPGet, Traffic.Hits, Traffic.Visitors FROM Sites INNER JOIN Traffic ON Sites.SiteId = Traffic.SiteId WHERE (Sites.SiteId = @SiteId) AND DATEPART(MONTH, Traffic.Date) = DATEPART(MONTH, @Date) AND DATEPART(YEAR, Traffic.Date) = DATEPART(YEAR, @Date)">
        <SelectParameters>
            <asp:QueryStringParameter DefaultValue="0" Name="SiteId" 
                QueryStringField="site" />
            <asp:QueryStringParameter DefaultValue="01.03.2010" Name="Date" Type="DateTime"
                QueryStringField="month" />
        </SelectParameters>
    </asp:SqlDataSource>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConnectionString="<%$ ConnectionStrings:statisticsConnectionString %>" 
        SelectCommand="SELECT * FROM [Sites] WHERE ([SiteId] = @SiteId)" >
        <SelectParameters>
            <asp:QueryStringParameter DefaultValue="0" Name="SiteId" 
                QueryStringField="site" Type="Int32" />
        </SelectParameters>
    </asp:SqlDataSource>
</asp:Content>

